import java.util.Scanner;

/**
 * Created by JiaJia on 2019/8/10 0010.
 */
public class Beike001 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            int n=scanner.nextInt();
            int min=Integer.MAX_VALUE;
            int[] arr=new int[n];
            int[] res=new int[2];
            for (int i = 0; i < n; i++) {
                arr[i]=scanner.nextInt();
            }
            for (int i = n-1; i >0;i--) {
                int ans=Math.abs(arr[i]-arr[i-1]);
                if (ans<=min){
                    res[0]=arr[i-1];
                    res[1]=arr[i];
                    min=ans;
                }
            }
            System.out.println(res[0]+" "+res[1]);
        }
        scanner.close();
    }
}